//JavaScript
var registerSession;
var respPresse


function setRegisterSession(registerSessionToSet){
  this.registerSession = registerSessionToSet;
}

function getArticlesPresse(){
  respPresse = false;
  var url = 'include/bd/presse_bd.php';
  $.getJSON(url
        ,gestionReponseArticlesPresse);
  setTimeout(function(){
  if (!respPresse){
      $('#articlesPresse').html("<DIV ALIGN='center'><IMG SRC='images/loading.gif' ALIGN='center'></DIV>");
  }
  },100);
  
}

function gestionReponseArticlesPresse(articlesPresse)
{
    respPresse = true;
    if (articlesPresse){
      if (articlesPresse.length > 0)
      {
          html = "";
          for (var i = 0; i < articlesPresse.length; i++){
            var article = articlesPresse[i];
            html += afficheArticlePresse(article);
          }
          $('#articlesPresse').html(html);
      }
    }
}

function afficheArticlePresse(article){
var html = ""+
	"<A HREF='presse/"+article.url+"' TARGET='_blank' class='blanc'>"+html_entity_decode(article.titre)+"</A>";
		if (registerSession == 1) {
        html +=""+ 
				" - <A class='blanc' HREF='index.php?page=update_presse&id_article_presse="+article.idPresse+"'>Editer cet article de presse</A>"; 
		}
  html +="<BR /><BR />";
return html;
}
